home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
725
< prev
next >
Wrap
Internet Message Format
|
1996-08-06
|
2KB
Path: news.crd.ge.com!usenet
From: Christopher R Volpe <volpe@ash.crd.ge.com>
Newsgroups: comp.std.c
Subject: Re: It this portable?
Date: Thu, 11 Apr 1996 14:38:35 -0400
Organization: GE Corporate Research & Development, Schenectady, NY
Message-ID: <316D51AB.C23@ash.crd.ge.com>
References: <Dpp1tv.4Kq@ukpsshp1.serigate.philips.nl>
NNTP-Posting-Host: bart.crd.ge.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
Stephen Baynes wrote:
>
> In a glossy newsletter from a company (who had better remain nameless) that
> sells tools for testing and validating C code the following bit of code was
> given as an example of implementation dependent but portable code across ISO
> C implementations. I know 'portable' is not a term used in the standard
Correct.
, let
> us assume it means conforming.
Bad choice. The term "conforming", when applied to user code (not to
implementations) is virtually meaningless. The U.S. Constitution is a
conforming piece of C code, or at least could be, given the existence of
a hypothetical compiler which makes it so.
I suspect the intended characteristic here is one that has been
informally dubbed "strongly conforming", meaning it violates no syntax
rule or semantic constraint, and does not invoke undefined behavior.
> Is this program conforming, giving an
> implementation defined result (regardless of the fact the result is probably
> not the one intended) or is it going to give undefined behaviour?
>
>
> #include <stdio.h>
> #include <limits.h>
> int main( void )
> {
> printf( "%d", UINT_MAX );
> return 0;
> }
>
> My vote is for undefined, but can anyone construct an argument based on
> the represention of integers that makes it implmentation defined?
Well, my vote is for implementation-defined, or at worst, unspecified,
but I can be convinced otherwise. Ints and unsigned-ints are required to
be the same size, I believe, and so the result should depend only on
the interpretation of the UINT_MAX bit pattern as a signed int.
My gut feeling is that there's no reason why a reasonable implementation
should crash from the above code.
--
Chris Volpe Phone: (518) 387-7766 (Dial Comm 8*833
GE Corporate R&D Fax: (518) 387-6560
PO Box 8, Schenectady, NY 12301 Email: volpecr@crd.ge.com